package com.fxwater.websocket.domain;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: 王明朝
 * @Date: 2019/8/17 10:17
 */
public class RedisCacheManager {

    private Map<String, List<RedisCacheInfo>> sceneCacheInfo = new HashMap<>();

    private RedisCacheManager(){

    }

    public static RedisCacheManager getInstance(){
        return RedisCacheManagerFactory.MANAGER;
    }

    private static class RedisCacheManagerFactory {
        public static  RedisCacheManager  MANAGER = new  RedisCacheManager();
    }

    public void registCacheInfo(RedisCacheInfo redisCacheInfo){
        if(sceneCacheInfo.containsKey(redisCacheInfo.getSceneId())){
            sceneCacheInfo.get(redisCacheInfo.getSceneId()).add(redisCacheInfo);
        } else {
            sceneCacheInfo.put(redisCacheInfo.getSceneId(),new ArrayList<>());
            sceneCacheInfo.get(redisCacheInfo.getSceneId()).add(redisCacheInfo);
        }
    }

    public List<RedisCacheInfo> getCacheInfoBySceneIId(String sceneId){
        return sceneCacheInfo.get(sceneId);
    }
}
